// 这是初始化加载
window.onload = function(){
  // document.getElementsByClassName('.lastTop').on('click',toTop())
  // $('.lastTop').on('mouseover',toTop())
  // $('.lastElse').on('click',changeSlide(true))
  // $('.lastHover').click(changeSlide(false))
    $('.coNames').on('mouseover',function(){
      $('.coNames').css('display','flex');
    })
    $('.proFirstCont img').on('mouseover',function(){
      $('.coNames').css('display','flex');
    })
    $('.coNames').on('mouseout',function(){
      $('.coNames').css('display','none');
    })
    $('.proFirstCont img').on('mouseout',function(){
      $('.coNames').css('display','none');
    })
    var mySwiper = new Swiper ('.sliderA', {
        // direction: 'vertical', // 垂直切换选项
        // loop: true, // 循环模式选项
        width: window.innerWidth,
        autoHeight:true,
        // 如果需要分页器
        pagination: {
          el: '.swiper-pagination',
        },
        
        // 如果需要前进后退按钮
        navigation: {
          nextEl: '.swiper-button-next',
          prevEl: '.swiper-button-prev',
        },
        
        // 如果需要滚动条
        scrollbar: {
          el: '.swiper-scrollbar',
        },
      })        
      
          console.log($($('.active')[0]));
          $($('.active')[0].nextElementSibling).show()
          // 下划线
          $('.nav ul li').mouseover(function(){
            
            $($(this)[0].children[1]).show()
            
          })
          $('.nav ul li').mouseleave(function(){
            // console.log($(this)[0].children[0].className=='links active');
            
            if($(this)[0].children[0].className!='links active'){
              $($(this)[0].children[1]).hide()
            }
            // $($(this)[0].children[1]).hide()
          })

      $('.fourthContent').height($('.fourthContent').width()/120*45)


      // product切换效果
      var before = $('#imgBefore')
      var after = $('#imgAfter')
      before.show()
      before.mouseover(function(){
        before.hide()
        after.fadeIn()
      })
      after.mouseleave(
        function(){
        after.hide()
        before.fadeIn()
        }
      )






}

// 方法
function submit(){
  // $('#name').val()
  let a = $('#name')
  let b = $('#email')
  let c = $('#needed')
  let d = $('#tel')
  let e = $('#company')
  // if(a.val())
  var xhr = new XMLHttpRequest();
  xhr.timeout = 3000;
  xhr.ontimeout = function (event) {
      alert("请求超时！");
  }
  var formJson = {
    'personName':a.val(),
    'email':b.val(),
    'need':c.val(),
    'telephone':d.val(),
    'company':e.val()
  }
  if(a.val()==''){
    alert('请填写姓名')
  }else if(b.val()==""){
    alert('请填写电子邮件')
  }else if(d.val()==""){
    alert('请填写联系电话')
  }else{
    xhr.open('POST', 'http://192.168.147.32:8080/srp/mh/mh-register!add.action');
    xhr.send(JSON.stringify(formJson));
    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4 && xhr.status == 200) {
          if(xhr.responseText.success==false){
  
          }else{
            alert('提交成功')
          }
            // alert(xhr.responseText);
        }
        else {
            alert('请检查网络设置');
        }
    }
  
  }
  
  
}
function subCo(){

  
    // $('#name').val()
    let c = $('#coneed')
    let b = $('#cotel')
    let a = $('#coname')
    let d = $('#coemail')
    // let e = $('#company')
    // if(a.val())
    var xhr = new XMLHttpRequest();
    xhr.timeout = 3000;
    xhr.ontimeout = function (event) {
        alert("请求超时！");
    }
    var formJson = {
      'personName':a.val(),
      'company':d.val(),
      'interest':c.val(),
      'telephone':b.val()
  
    }
    if(a.val()==''){
      alert('请填写姓名')
    }else if(d.val()==""){
      alert('请填写您的公司名称')
    }else if(b.val()==""){
      alert('请填写联系电话')
    }else{
      xhr.open('POST', 'http://192.168.147.32:8080/srp/mh/mh-test!add.action');
      xhr.send(JSON.stringify(formJson));
      xhr.onreadystatechange = function () {
          if (xhr.readyState == 4 && xhr.status == 200) {
            if(xhr.responseText.success){
              alert('提交失败');
            }else{
              alert('提交成功')
            }
              // alert(xhr.responseText);
              
          }
          else {
              
          }
      }
    }
  }
function datago(){

  
    // $('#name').val()
    let a = $('#1')
    let b = $('#2')
    let c = $('#3')
    let d = $('#4')
    let e = $('#5')
    let f = $('#6')
    let g = $('#7')
    let h = $('#8')
    // let e = $('#company')
    // if(a.val())
    var xhr = new XMLHttpRequest();
    xhr.timeout = 3000;
    xhr.ontimeout = function (event) {
        alert("请求超时！");
    }
    var formJson = {
      'company':a.val(),
      'parentCompany':b.val(),
      'country':c.val(),
      'province':d.val(),
      'telephone':e.val(),
      'email':f.val(),
      'companyUrl':g.val(),
      'direction':h.val()
    }
    if(a.val()==''){
      alert('请填写公司名称')
    }else if(f.val()==""){
      alert('请填写对接人邮箱')
    }else if(e.val()==""){
      alert('请填写联系电话')
    }else{
      xhr.open('POST', 'http://192.168.147.32:8080/srp/mh/mh-test!add.action');
      xhr.send(JSON.stringify(formJson));
      xhr.onreadystatechange = function () {
          if (xhr.readyState == 4 && xhr.status == 200) {
            if(xhr.responseText.success){
              alert('提交失败');
            }else{
              alert('提交成功')
            }
              // alert(xhr.responseText);
              
          }
          else {
              
          }
      }
    }
  }


  

  toTop = function(){
    $("body,html").scrollTop(0);
  }
  changeSlide = function(arg){
    
   

    if(arg){
      $('.qwbli').hide()
      $('.qwbhover').fadeIn(10)
    }else{
      $('.qwbhover').hide()
      $('.qwbli').fadeIn(10)
    }
  }
  
